package io.adrainty.bolee.insurance.models.entity;

import cn.hutool.core.util.DesensitizedUtil;
import io.adrainty.bolee.framework.commons.basic.BaseEntity;
import io.adrainty.bolee.framework.commons.basic.EnableEnum;
import io.adrainty.bolee.insurance.models.valobj.UnderwritingStateEnum;
import io.adrainty.bolee.insurance.models.valobj.WarrantyStateEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.io.Serial;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>WarrantyEntity</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description 保险合同Vo
 * @since 2025/8/26 10:17:22
 */

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(description = "保险合同Vo")
public class WarrantyEntity extends BaseEntity {

    @Serial
    private static final long serialVersionUID = 6102464782370988753L;

    @Schema(description = "保险ID")
    private Long insuranceId;

    @Schema(description = "保险名称")
    private String insuranceName;

    @Schema(description = "投保详情")
    private String insuranceJson;

    @Schema(description = "保险分类编号")
    private Long categoryNo;

    @Schema(description = "保单编号")
    private String warrantyNo;

    @Schema(description = "投保人姓名")
    private String applicantName;

    @Schema(description = "投保人身份证号码")
    private String applicantIdentityCard;

    @Schema(description = "企业编号")
    private String companyNo;

    @Schema(description = "企业名称")
    private String companyName;

    @Schema(description = "保障起始时间")
    private LocalDateTime safeguardStartTime;

    @Schema(description = "保障截止时间")
    private LocalDateTime safeguardEndTime;

    @Schema(description = "保费")
    private BigDecimal premium;

    @Schema(description = "总保费")
    private BigDecimal premiums;

    @Schema(description = "自动延保（0是 1否）")
    private String autoWarrantyExtension;

    @Schema(description = "状态（0待付款 1待生效 2保障中  3 逾期中止 4理赔终止 5 复效中止 6 复效终止  6满期终止 7 拒保 8 犹豫期退保 9 协议退保   ）")
    private WarrantyStateEnum warrantyState;

    @Schema(description = "核保状态(0发送失败 1核保中 2核保失败 3核保成功  )")
    private UnderwritingStateEnum underwritingState;

    @Schema(description = "批保状态(0未批保 1批保发送失败 2批保中 3批保通过 4.保批不通过)")
    private String approveState;

    @Schema(description = "总期数")
    private Integer periods;

    @Schema(description = "周期单位")
    private String periodicUnit;

    @Schema(description = "已缴纳期数")
    private Integer dutyPeriod;

    @Schema(description = "排序")
    private Integer sortNo;

    @Schema(description = "犹豫期截止时间")
    private LocalDateTime hesitationTime;

    @Schema(description = "等待期截止时间")
    private LocalDateTime waitTime;

    @Schema(description = "保单宽限")
    private Integer grace;

    @Schema(description = "宽限单位")
    private String graceUnit;

    @Schema(description = "保单复效")
    private Integer revival;

    @Schema(description = "复效单位")
    private String revivalUnit;

    @Schema(description = "批量操作：主键ID")
    private String[] checkedIds;

    @Schema(description = "被投保人关系")
    private List<CustomerRelationEntity> customerRelationVOs;

    @Schema(description = "代理人Id")
    private String agentId;

    @Schema(description = "代理人姓名")
    private String agentName;

    @Schema(description = "合同状态数组")
    private String[] warrantyStates;

    @Schema(description = "合同订单")
    private List<WarrantyOrderEntity> warrantyOrderVOList;

    @Schema(description = "被投保人")
    private List<WarrantyInsuredEntity> insuredVOS;

    @Schema(description = "保单编号列表")
    private List<String> warrantyNos;

    @Schema(description = "数据状态：0正常 1禁用")
    private EnableEnum dataState;

    /**
     * 脱敏数据
     */
    public void desensitize() {
        this.applicantIdentityCard = DesensitizedUtil.idCardNum(this.applicantIdentityCard, 1, 4);
        this.applicantName = DesensitizedUtil.chineseName(this.applicantName);
        this.agentName = DesensitizedUtil.chineseName(this.agentName);
    }

}
